function [pdf,logpdf]= mnormfast(x,mu,sig); 
% X must be n x T such that the columns are the number of iterations 
if  nargin < 2
    error('Missing Arguments to compute normal fast');
    return 
else
    [n1,it]=size(x);
    mu=mu(:); 
    n2=size(mu,1); 
    n3=(size(sig))';
    m1=[n1;n1]; 
    if (n1 ~= n2) | (m1 ~= n3); 
        error('Wrong Dimension in Inputs')
    end; 
end; 

if nargin==1; 
    mu=zeros(n1,1); 
    sig=zeros(n1); 
end;

pdf=zeros(it,1); 
logpdf=zeros(it,1); 
 

xdem = x - repmat( mu(:) , [1 it] ); 


insig = sig \ eye(n1); 
de=det(sig); 

if de == 0; 
    de=0.5*mydet(sig); 
else 
    de=0.5*log(de);
end

ii=1;
for ii=1:it;     
    %ft= 0.5*(  (x(:,ii)-mu)' )*insig*( x(:,ii)-mu ) ; 
    ft =0.5*( xdem(:,ii)' )*insig*( xdem(:,ii) ); 
    c=(n1/2)*log(2*pi); 
    logpdf(ii,1)=-(c+de+ft); 
    pdf(ii,1)=exp(logpdf(ii,1));     
end; 